package main

import (
	"cgs-server/internal/cgserver"
	"cgs-server/internal/cgserver/embedfile"
	"embed"
	"math/rand"
	"os"
	"runtime"
	"time"

	// Register sub packages.
	_ "cgs-server/cmd/win" // windows service api

	// Register `cgs-server/server/assets`
	_ "cgs-server/server/assets/animation"  // animation api
	_ "cgs-server/server/assets/audio"      // audio api
	_ "cgs-server/server/assets/character"  // character api
	_ "cgs-server/server/assets/material"   // material api
	_ "cgs-server/server/assets/mesh"       // mesh api
	_ "cgs-server/server/assets/particle"   // particle api
	_ "cgs-server/server/assets/prefab"     // prefab api
	_ "cgs-server/server/assets/scene"      // scene api
	_ "cgs-server/server/assets/screenshot" // screenshot api
	_ "cgs-server/server/assets/summary"    // summary api
	_ "cgs-server/server/assets/texture"    // texture api
	_ "cgs-server/server/assets/video"      // video api

	// Register `cgs-server/server/category`
	_ "cgs-server/server/category" // category api

	// Register `cgs-server/server/export`
	_ "cgs-server/server/export/examples" // examples api
	_ "cgs-server/server/export/scene"    // scene api

	// Register `cgs-server/server/gis`
	_ "cgs-server/server/gis" // gis api

	// Register `cgs-server/server/system`
	_ "cgs-server/server/system/authority"  // authority api
	_ "cgs-server/server/system/config"     // config api
	_ "cgs-server/server/system/department" // department api
	_ "cgs-server/server/system/initialize" // initialize api
	_ "cgs-server/server/system/login"      // login api
	_ "cgs-server/server/system/register"   // register api
	_ "cgs-server/server/system/role"       // role api
	_ "cgs-server/server/system/user"       // user api

	// Register `cgs-server/server/tools`
	_ "cgs-server/server/tools/backup_database" // backup_database api
	_ "cgs-server/server/tools/clean_scenes"    // clean_scenes api
	_ "cgs-server/server/tools/plugin"          // plugin api
	_ "cgs-server/server/tools/typeface"        // typeface api

	// Register `cgs-server/server/upload`
	_ "cgs-server/server/upload" // upload api

	_ "cgs-server/server/assets/cgs"
	_ "cgs-server/server/assets/cgs_map"
	_ "cgs-server/server/assets/cgs_portal"
	_ "cgs-server/server/assets/cgs_portal/category"
	_ "cgs-server/server/assets/cgs_portal/visual"
	_ "cgs-server/server/assets/cgs_portal/visual_db"
	_ "cgs-server/server/assets/cgs_portal/visual_map"

	_ "cgs-server/server/assets/cgs_mingdao"
	// Cgs 表格
	_ "cgs-server/server/assets/cgs_worksheet"
	_ "cgs-server/server/assets/earth"
	_ "cgs-server/server/system/lic"
	_ "cgs-server/server/system/sdk"
	_ "cgs-server/server/system/tenant" // tenant api
)

//go:embed default_models
var defaultModels embed.FS

//go:embed template
var template embed.FS

//go:embed static/*
var static embed.FS

// Here we just import and execute the root command. Keep this file tidy.
//
// First, run `go install` to install third-party dependencies.
// Then, run `go build` in this folder to create the binary file.
func main() {
	rand.Seed(time.Now().UTC().UnixNano())
	if len(os.Getenv("GOMAXPROCS")) == 0 {
		runtime.GOMAXPROCS(runtime.NumCPU())
	}

	embedfile.SetEmbedFile(&defaultModels, &template, &static)

	cgserver.NewApp("cgs-server").Run()
}
